#		    l i b Q G L V i e w e r
#	C o m p i l a t i o n    c o n f i g u r a t i o n

# Run "qmake; make; make install" to compile and install the library on Unix systems.
# Optional arguments can tune install paths (as in "qmake PREFIX=$HOME"). See doc/download.html for details.

#TEMPLATE = lib
#TARGET = QGLGraphicsViewer
#VERSION = 2.6.4

INCLUDEPATH += $$PWD \
            $$PWD/../

#CONFIG += qt opengl warn_on shared thread create_prl rtti no_keywords

QGL_HEADERS = \
#          $$PWD/QGLGraphicsViewer.h \
          $$PWD/camera.h \
          $$PWD/manipulatedFrame.h \
          $$PWD/manipulatedCameraFrame.h \
          $$PWD/frame.h \
          $$PWD/constraint.h \
          $$PWD/keyFrameInterpolator.h \
          $$PWD/mouseGrabber.h \
          $$PWD/quaternion.h \
          $$PWD/vec.h \
          $$PWD/domUtils.h \
          $$PWD/config.h \
          $$PWD/qglgraphicsviewer.h \
#          $$PWD/qglgraphicsview.h

SOURCES += \
#          $$PWD/QGLGraphicsViewer.cpp \
          $$PWD/camera.cpp \
          $$PWD/manipulatedFrame.cpp \
          $$PWD/manipulatedCameraFrame.cpp \
          $$PWD/frame.cpp \
          $$PWD/saveSnapshot.cpp \
          $$PWD/constraint.cpp \
          $$PWD/keyFrameInterpolator.cpp \
          $$PWD/mouseGrabber.cpp \
          $$PWD/quaternion.cpp \
          $$PWD/vec.cpp \
#          $$PWD/qglgraphicsview.cpp
    $$PWD/qglgraphicsviewer.cpp

HEADERS += $${QGL_HEADERS}
#DISTFILES += $$PWD/QGLGraphicsViewer-icon.xpm
#DESTDIR = $${PWD}

#TRANSLATIONS += $$PWD/QGLGraphicsViewer_fr.ts

QT += xml opengl

equals (QT_MAJOR_VERSION, 5) {
        QT += gui widgets
}

#!isEmpty( QGLGraphicsViewer_STATIC ) {
#  CONFIG += staticlib
#}

# -----------------------------------
# --  I m a g e I n t e r f a c e  --
# -----------------------------------
FORMS += $$PWD/ImageInterface.ui

# ---------------------------------------------
# --  V e c t o r i a l   R e n d e r i n g  --
# ---------------------------------------------
# In case of compilation troubles with vectorial rendering, uncomment this line
# DEFINES += NO_VECTORIAL_RENDER

contains( DEFINES, NO_VECTORIAL_RENDER ) {
  message( Vectorial rendering disabled )
} else {
  FORMS += $$PWD/VRenderInterface.ui

  SOURCES += \
        $$PWD/VRender/BackFaceCullingOptimizer.cpp \
        $$PWD/VRender/BSPSortMethod.cpp \
        $$PWD/VRender/EPSExporter.cpp \
        $$PWD/VRender/Exporter.cpp \
        $$PWD/VRender/FIGExporter.cpp \
        $$PWD/VRender/gpc.cpp \
        $$PWD/VRender/ParserGL.cpp \
        $$PWD/VRender/Primitive.cpp \
        $$PWD/VRender/PrimitivePositioning.cpp \
        $$PWD/VRender/TopologicalSortMethod.cpp \
        $$PWD/VRender/VisibilityOptimizer.cpp \
        $$PWD/VRender/Vector2.cpp \
        $$PWD/VRender/Vector3.cpp \
        $$PWD/VRender/NVector3.cpp \
        $$PWD/VRender/VRender.cpp

  VRENDER_HEADERS = \
        $$PWD/VRender/AxisAlignedBox.h \
        $$PWD/VRender/Exporter.h \
        $$PWD/VRender/gpc.h \
        $$PWD/VRender/NVector3.h \
        $$PWD/VRender/Optimizer.h \
        $$PWD/VRender/ParserGL.h \
        $$PWD/VRender/Primitive.h \
        $$PWD/VRender/PrimitivePositioning.h \
        $$PWD/VRender/SortMethod.h \
        $$PWD/VRender/Types.h \
        $$PWD/VRender/Vector2.h \
        $$PWD/VRender/Vector3.h \
        $$PWD/VRender/VRender.h

  HEADERS += $${VRENDER_HEADERS}
}


# ---------------
# --  U n i x  --
# ---------------
#unix {
#        CONFIG -= debug debug_and_release
#        CONFIG += release

#        # INCLUDE_DIR and LIB_DIR specify where to install the include files and the library.
#        # Use qmake INCLUDE_DIR=... LIB_DIR=... , or qmake PREFIX=... to customize your installation.
#        isEmpty( PREFIX ) {
#                PREFIX_=/usr/local
#        } else {
#                PREFIX_=$${PREFIX}
#        }
#        isEmpty( LIB_DIR ) {
#                LIB_DIR_ = $${PREFIX_}/lib
#        } else {
#                LIB_DIR_ = $${LIB_DIR}
#        }
#        isEmpty( INCLUDE_DIR ) {
#                INCLUDE_DIR_ = $${PREFIX_}/include
#        } else {
#                INCLUDE_DIR_ = $${INCLUDE_DIR}
#        }
#        isEmpty( DOC_DIR ) {
#                macx|darwin-g++ {
#                        isEmpty( PREFIX ) {
#                                DOC_DIR = $${PWD}/Library/Developer/Shared/Documentation/QGLGraphicsViewer
#                        } else {
#                                DOC_DIR = $${PREFIX}/Shared/Documentation/QGLGraphicsViewer
#                        }
#                } else {
#                        DOC_DIR = $${PREFIX_}/share/doc/QGLGraphicsViewer
#                }
#        }

#        # GLUT for Unix architecture
#        !isEmpty( USE_GLUT ) {
#                QMAKE_LIBS_OPENGL += -lglut
#        }

#        macx|darwin-g++ {
#                # GLU is part of the OpenGL framework
#        } else {
#                QMAKE_LIBS_OPENGL += -lGLU

#                isEmpty( NO_QT_VERSION_SUFFIX ) {
#                        equals (QT_MAJOR_VERSION, 4) {
#                                TARGET = $$join(TARGET,,,-qt4)
#                        }
#                        equals (QT_MAJOR_VERSION, 5) {
#                                TARGET = $$join(TARGET,,,-qt5)
#                        }
#                }
#        }

#        MOC_DIR = .moc
#        OBJECTS_DIR = .obj

#        # Adds a -P option so that "make install" as root creates files owned by root and links are preserved.
#        # This is not a standard option, and it may have to be removed on old Unix flavors.
#        !hpux {
#                QMAKE_COPY_FILE = $${QMAKE_COPY_FILE} -P
#        }

#        # Make much smaller libraries (and packages) by removing debugging informations
#        QMAKE_CFLAGS_RELEASE -= -g
#        QMAKE_CXXFLAGS_RELEASE -= -g

#        # install header
#        include.path = $${INCLUDE_DIR_}/QGLGraphicsViewer
#        # Should be $$replace(TRANSLATIONS, .ts, .qm), but 'replace' only appeared in Qt 4.3
#        include.files = $${QGL_HEADERS} QGLGraphicsViewer_fr.qm

#        # install documentation html
#        documentation.path = $${DOC_DIR}
#        documentation.files = ../doc/*.html ../doc/*.css  ../doc/*.qch

#        # install documentation images
#        docImages.path = $${DOC_DIR}/images
#        docImages.files = ../doc/images/*

#        # install documentation examples
#        #docExamples.path = $${DOC_DIR}/examples
#        #docExamples.files = ../examples/*../examples/*/*

#        # install documentation refManual
#        docRefManual.path = $${DOC_DIR}/refManual
#        docRefManual.files = ../doc/refManual/*

#        # install static library
#        #staticlib.extra = make -f Makefile.Release staticlib
#        #staticlib.path = $${LIB_DIR_}
#        #staticlib.files = lib$${TARGET}.a

#        # install library
#        target.path = $${LIB_DIR_}

#        # "make install" configuration options
#        INSTALLS += target include documentation docImages docRefManual
#}


## -------------------
## --  M a c O S X  --
## -------------------
#macx|darwin-g++ {
#        # Default setting creates a Mac framework. Comment out this line to create a dylib instead.
#        !staticlib: CONFIG += lib_bundle

#        include.files += QGLGraphicsViewer.icns

#    # Or whatever exists in /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/
#    QMAKE_MAC_SDK = macosx10.12

#        lib_bundle {
#                FRAMEWORK_HEADERS.version = Versions
#                # Should be $$replace(TRANSLATIONS, .ts, .qm), but 'replace' is only available in Qt 4.3
#                FRAMEWORK_HEADERS.files = $${QGL_HEADERS} QGLGraphicsViewer.icns QGLGraphicsViewer_fr.qm
#                FRAMEWORK_HEADERS.path = Headers
#                QMAKE_BUNDLE_DATA += FRAMEWORK_HEADERS

#                # So that the path *.h exists
#                QMAKE_POST_LINK=cd $$DESTDIR/QGLGraphicsViewer.framework/Headers && (test -L QGLGraphicsViewer || ln -s . QGLGraphicsViewer)

#                # Specific paths for the installation of the framework.
#                !isEmpty( LIB_DIR ) {
#                        target.path = $${LIB_DIR}
#                }

#                # Framework already contains includes
#                INSTALLS -= include
#        }

#        # GLUT for Mac architecture
#        !isEmpty( USE_GLUT ) {
#                QMAKE_LIBS_OPENGL -= -lglut
#                QMAKE_LIBS_OPENGL += -framework GLUT -lobjc
#        }
#}


# ---------------------
# --  W i n d o w s  --
# ---------------------
win32 {
        # Windows requires a debug lib version to link against debug applications
        #CONFIG += debug_and_release build_all

        # Needed by Intel C++, (icl.exe) so that WINGDIAPI is a defined symbol in gl.h.
#        DEFINES += WIN32

#        staticlib {
#                DEFINES += QGLGraphicsViewer_STATIC
#        } else {
#                DEFINES += CREATE_QGLGraphicsViewer_DLL
#        }

        CONFIG += embed_manifest_dll

        # Use native OpenGL drivers with Qt5.5
        # No longer implicit since the ANGLE driver is now an alternative
        LIBS += -lopengl32 -lglu32

        # TP : C++ source code
        # GR : Enables run-time type information (RTTI).
        # Zi : Generates complete debugging information (removed)
        # EHs : The exception-handling model that catches C++ exceptions only and tells the
        #       compiler to assume that functions declared as extern "C" may throw an exception.
        # FS : Enable parallel compilation
        # Any feedback on these flags is welcome.
        !win32-g++ {
                QMAKE_CXXFLAGS += -TP -GR
                DEFINES += NOMINMAX
                win32-msvc {
                        QMAKE_CXXFLAGS += -EHs -FS
                } else {
                        QMAKE_CXXFLAGS += -EHs
                }
        }
}


#build_pass:CONFIG(debug, debug|release) {
#  unix: TARGET = $$join(TARGET,,,_debug)
#  else: TARGET = $$join(TARGET,,,d)
#}
